<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Origami::Array</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Origami::Array</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/origami/array_rb.html">
                origami/array.rb
                </a>
        <br />
                <a href="../../files/origami/obfuscation_rb.html">
                origami/obfuscation.rb
                </a>
        <br />
                <a href="../../files/origami/docmdp_rb.html">
                origami/docmdp.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                ::Array
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Class representing an <a href="Array.html">Array</a> <a
href="Object.html">Object</a>. Arrays contain a set of <a
href="Object.html">Object</a>.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000472">+</a>&nbsp;&nbsp;
      <a href="#M000473">&lt;&lt;</a>&nbsp;&nbsp;
      <a href="#M000474">[]=</a>&nbsp;&nbsp;
      <a href="#M000469">new</a>&nbsp;&nbsp;
      <a href="#M000470">pre_build</a>&nbsp;&nbsp;
      <a href="#M000476">real_type</a>&nbsp;&nbsp;
      <a href="#M000471">to_a</a>&nbsp;&nbsp;
      <a href="#M000478">to_docmdp_str</a>&nbsp;&nbsp;
      <a href="#M000477">to_obfuscated_str</a>&nbsp;&nbsp;
      <a href="#M000475">value</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->
    <div id="includes">
      <h3 class="section-bar">Included Modules</h3>

      <div id="includes-list">
        <span class="include-name"><a href="Object.html">Origami::Object</a></span>
      </div>
    </div>

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">names_cache</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">strings_cache</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">xref_cache</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000469" class="method-detail">
        <a name="M000469"></a>

        <div class="method-heading">
          <a href="#M000469" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(data = [])</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Creates a <a href="Array.html#M000469">new</a> <a href="PDF.html">PDF</a>
<a href="Array.html">Array</a> <a href="Object.html">Object</a>.
</p>
<table>
<tr><td valign="top"><em>data</em>:</td><td>An array of objects.

</td></tr>
</table>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000469-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000469-source">
<pre>
    <span class="ruby-comment cmt"># File origami/array.rb, line 49</span>
49:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">data</span> = [])
50:       <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;Expected type Array, received #{data.class}.&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-operator">::</span><span class="ruby-constant">Array</span>)
51:       <span class="ruby-keyword kw">super</span>()
52: 
53:       <span class="ruby-ivar">@strings_cache</span> = []
54:       <span class="ruby-ivar">@names_cache</span> = []
55:       <span class="ruby-ivar">@xref_cache</span> = {}
56: 
57:       <span class="ruby-identifier">i</span> = <span class="ruby-value">0</span>
58:       <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">size</span>
59:         <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">val</span> = <span class="ruby-identifier">data</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">to_o</span>
60:           <span class="ruby-keyword kw">when</span> <span class="ruby-constant">String</span> <span class="ruby-keyword kw">then</span> <span class="ruby-ivar">@strings_cache</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">val</span>)
61:           <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Name</span> <span class="ruby-keyword kw">then</span> <span class="ruby-ivar">@names_cache</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">val</span>)
62:           <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Reference</span> <span class="ruby-keyword kw">then</span> 
63:             (<span class="ruby-ivar">@xref_cache</span>[<span class="ruby-identifier">val</span>] <span class="ruby-operator">||=</span> []).<span class="ruby-identifier">push</span>(<span class="ruby-keyword kw">self</span>)
64:           <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Dictionary</span>,<span class="ruby-constant">Array</span> <span class="ruby-keyword kw">then</span> 
65:             <span class="ruby-ivar">@strings_cache</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">val</span>.<span class="ruby-identifier">strings_cache</span>)
66:             <span class="ruby-ivar">@names_cache</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">val</span>.<span class="ruby-identifier">names_cache</span>)
67:             <span class="ruby-ivar">@xref_cache</span>.<span class="ruby-identifier">update</span>(<span class="ruby-identifier">val</span>.<span class="ruby-identifier">xref_cache</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ref</span>, <span class="ruby-identifier">cache1</span>, <span class="ruby-identifier">cache2</span><span class="ruby-operator">|</span>
68:               <span class="ruby-identifier">cache1</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">cache2</span>)  
69:             <span class="ruby-keyword kw">end</span>
70: 
71:             <span class="ruby-identifier">val</span>.<span class="ruby-identifier">strings_cache</span>.<span class="ruby-identifier">clear</span>
72:             <span class="ruby-identifier">val</span>.<span class="ruby-identifier">names_cache</span>.<span class="ruby-identifier">clear</span>
73:             <span class="ruby-identifier">val</span>.<span class="ruby-identifier">xref_cache</span>.<span class="ruby-identifier">clear</span>
74:         <span class="ruby-keyword kw">end</span>
75: 
76:         <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">i</span>] = <span class="ruby-identifier">val</span>
77:         <span class="ruby-identifier">i</span> = <span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
78:       <span class="ruby-keyword kw">end</span>
79:       
80:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000472" class="method-detail">
        <a name="M000472"></a>

        <div class="method-heading">
          <a href="#M000472" class="method-signature">
          <span class="method-name">+</span><span class="method-args">(other)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000472-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000472-source">
<pre>
     <span class="ruby-comment cmt"># File origami/array.rb, line 132</span>
132:     <span class="ruby-keyword kw">def</span> <span class="ruby-operator">+</span>(<span class="ruby-identifier">other</span>)
133:       
134:       <span class="ruby-identifier">a</span> = <span class="ruby-constant">Origami</span><span class="ruby-operator">::</span><span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_a</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">to_a</span>,  <span class="ruby-identifier">is_indirect?</span>)
135:       <span class="ruby-identifier">a</span>.<span class="ruby-identifier">no</span>, <span class="ruby-identifier">a</span>.<span class="ruby-identifier">generation</span> = <span class="ruby-ivar">@no</span>, <span class="ruby-ivar">@generation</span>
136:       
137:       <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">a</span>
138:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000473" class="method-detail">
        <a name="M000473"></a>

        <div class="method-heading">
          <a href="#M000473" class="method-signature">
          <span class="method-name">&lt;&lt;</span><span class="method-args">(item)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000473-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000473-source">
<pre>
     <span class="ruby-comment cmt"># File origami/array.rb, line 140</span>
140:     <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;&lt;</span>(<span class="ruby-identifier">item</span>)
141:       <span class="ruby-identifier">obj</span> = <span class="ruby-identifier">item</span>.<span class="ruby-identifier">to_o</span>
142:       <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">parent</span> = <span class="ruby-keyword kw">self</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">is_indirect?</span>
143: 
144:       <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">obj</span>)
145:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000474" class="method-detail">
        <a name="M000474"></a>

        <div class="method-heading">
          <a href="#M000474" class="method-signature">
          <span class="method-name">[]=</span><span class="method-args">(key,val)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000474-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000474-source">
<pre>
     <span class="ruby-comment cmt"># File origami/array.rb, line 147</span>
147:     <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]=</span>(<span class="ruby-identifier">key</span>,<span class="ruby-identifier">val</span>)
148:       <span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span> = <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_o</span>, <span class="ruby-identifier">val</span>.<span class="ruby-identifier">to_o</span>
149:       <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_o</span>,<span class="ruby-identifier">val</span>.<span class="ruby-identifier">to_o</span>)
150:  
151:       <span class="ruby-identifier">val</span>.<span class="ruby-identifier">parent</span> = <span class="ruby-keyword kw">self</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">is_indirect?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">equal?</span>(<span class="ruby-keyword kw">self</span>)
152: 
153:       <span class="ruby-identifier">val</span>
154:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000470" class="method-detail">
        <a name="M000470"></a>

        <div class="method-heading">
          <a href="#M000470" class="method-signature">
          <span class="method-name">pre_build</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000470-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000470-source">
<pre>
    <span class="ruby-comment cmt"># File origami/array.rb, line 82</span>
82:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pre_build</span>
83:       <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">map!</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">obj</span><span class="ruby-operator">|</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">to_o</span>}
84:       
85:       <span class="ruby-keyword kw">super</span>
86:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000476" class="method-detail">
        <a name="M000476"></a>

        <div class="method-heading">
          <a href="#M000476" class="method-signature">
          <span class="method-name">real_type</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000476-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000476-source">
<pre>
     <span class="ruby-comment cmt"># File origami/array.rb, line 158</span>
158:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">real_type</span> ; <span class="ruby-constant">Origami</span><span class="ruby-operator">::</span><span class="ruby-constant">Array</span> <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000471" class="method-detail">
        <a name="M000471"></a>

        <div class="method-heading">
          <a href="#M000471" class="method-signature">
          <span class="method-name">to_a</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Converts self into a Ruby array.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000471-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000471-source">
<pre>
     <span class="ruby-comment cmt"># File origami/array.rb, line 116</span>
116:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_a</span>
117:       <span class="ruby-keyword kw">super</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
118:         <span class="ruby-identifier">item</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Origami</span><span class="ruby-operator">::</span><span class="ruby-constant">Object</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">value</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">item</span>
119:       }
120:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000478" class="method-detail">
        <a name="M000478"></a>

        <div class="method-heading">
          <a href="#M000478" class="method-signature">
          <span class="method-name">to_docmdp_str</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000478-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000478-source">
<pre>
    <span class="ruby-comment cmt"># File origami/docmdp.rb, line 77</span>
77:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_docmdp_str</span>
78:       <span class="ruby-identifier">str</span> = [ <span class="ruby-value">7</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">length</span> ].<span class="ruby-identifier">pack</span>(<span class="ruby-value str">&quot;CN&quot;</span>)
79: 
80:       <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">obj</span><span class="ruby-operator">|</span>
81:         <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">to_docmdp_str</span>
82:       <span class="ruby-keyword kw">end</span>
83: 
84:       <span class="ruby-identifier">str</span>
85:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000477" class="method-detail">
        <a name="M000477"></a>

        <div class="method-heading">
          <a href="#M000477" class="method-signature">
          <span class="method-name">to_obfuscated_str</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000477-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000477-source">
<pre>
     <span class="ruby-comment cmt"># File origami/obfuscation.rb, line 136</span>
136:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_obfuscated_str</span>
137:       <span class="ruby-identifier">content</span> = <span class="ruby-constant">TOKENS</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">+</span> <span class="ruby-constant">Obfuscator</span>.<span class="ruby-identifier">junk_spaces</span>
138:       <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
139:         <span class="ruby-identifier">content</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">to_o</span>.<span class="ruby-identifier">to_obfuscated_str</span> <span class="ruby-operator">+</span> <span class="ruby-constant">Obfuscator</span>.<span class="ruby-identifier">junk_spaces</span>
140:       }
141: 
142:       <span class="ruby-identifier">content</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">TOKENS</span>.<span class="ruby-identifier">last</span>
143: 
144:       <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">content</span>)
145:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000475" class="method-detail">
        <a name="M000475"></a>

        <div class="method-heading">
          <span class="method-name">value</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Array.html#M000471">to_a</a>
</p>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>